window.onload = function() {

    username.addEventListener("input", (e) => {
        console.log("正在输入", e.target.value)
    })

    let btn = document.querySelector("button")
    btn.addEventListener("click", (e) => {
        e.preventDefault()

        let username = document.getElementById("username").value
        let password = document.getElementById("password").value
        let data = {
            username:username,
            password:password
        }
        console.log(data)
// 172.19.1.251
        fetch("http://172.19.1.251:8080/login",{
            method:"POST",
            headers:{
                "content-Type":"application/json"
            },
            body:JSON.stringify(data)
        }).then((e)=>{
            console.log("输入成功")
            return e.text()
        }).then((e)=>{
            console.log(e)
        })
        .catch(()=>{
            console.log("输入失败")
        })
    })
    let dl = document.querySelector("#dl")
    dl.addEventListener("click",(e)=>{
        e.preventDefault()

        let username = document.getElementById("username").value
        let password = document.getElementById("password").value
        let data = {
            username:username,
            password:password
        }

        fetch("http://127.0.0.1:8080/login",{
            method:"GET"
        }).then(()=>{
            console.log("输入成功")
        }).catch(()=>{
            console.log("输入失败")
        })
    })
}